package com.xueyi.aixihu.controller;

import com.xueyi.aixihu.controller.base.BaseController;
import com.xueyi.aixihu.entity.vo.ApiNewsSortVo;
import com.xueyi.aixihu.entity.vo.ApiSystemTypeContentVo;
import com.xueyi.aixihu.entity.vo.ApiSystemTypeVo;
import com.xueyi.aixihu.reqeust.ApiSearchSystemTypeContentReq;
import com.xueyi.aixihu.response.base.BaseResponse;
import com.xueyi.aixihu.service.ApiSanWuGongKaiService;
import lombok.AllArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 描述
 *
 * @author 刘梓江
 * @date 2023-07-01 10:07
 */
@Validated
@RestController
@AllArgsConstructor
public class ApiSanWuGongKaiController extends BaseController {

    private final ApiSanWuGongKaiService apiSanWuGongKaiService;

    /**
     * 查询所有村/社区
     *
     * @return
     */
    @RequestMapping("/api/searchVillageCommunity")
    public BaseResponse<Object> searchVillageCommunity() {
        List<ApiNewsSortVo> apiNewsSortVos = apiSanWuGongKaiService.searchVillageCommunity();
        return BaseResponse.success(apiNewsSortVos);
    }

    /**
     * 获取指定模块（镇/村）的三务公开类型内容
     *
     * @param type
     * @return
     */
    @RequestMapping("/api/searchSystemType")
    public BaseResponse<Object> searchSystemType(@NotNull(message = "类型不能为空") Integer type) {
        List<ApiSystemTypeVo> apiSystemTypeVos = apiSanWuGongKaiService.searchSystemType(type);
        return BaseResponse.success(apiSystemTypeVos);
    }

    /**
     * 查询系统类型内容列表
     *
     * @param req
     * @return
     */
    @RequestMapping("/api/searchSystemTypeContent")
    public BaseResponse<Object> searchSystemTypeContent(@Validated ApiSearchSystemTypeContentReq req) {
        List<ApiSystemTypeContentVo> contentVos = apiSanWuGongKaiService.searchSystemTypeContent(req);
        return BaseResponse.success(contentVos);
    }

    /**
     * 查询指定内容详情信息
     *
     * @param id
     * @param searchType
     * @return
     */
    @RequestMapping("/api/searchStatementContentDesc")
    public BaseResponse<Object> searchStatementContentDesc(@NotNull(message = "编号为空") Integer id,@NotNull(message = "查询类型为空")Integer searchType) {
        ApiSystemTypeContentVo apiSystemTypeContentVo = apiSanWuGongKaiService.searchStatementContentDesc(id, searchType);
        return BaseResponse.success(apiSystemTypeContentVo);
    }
}
